package com.cskaoyan.controller.wx_user.exception;

import com.cskaoyan.bean.admin.Admin;
import com.cskaoyan.bean.configmanagement.WX;
import com.cskaoyan.bean.wx_feedback.exception.AddFeedbackException;
import com.cskaoyan.bean.wx_feedback.exception.WxFeedbackParamException;
import com.cskaoyan.bean.wx_footprint.exception.DeleteFootprintException;
import com.cskaoyan.bean.wx_resp.WxRespVo;
import com.cskaoyan.bean.wx_user.exception.AddUserException;
import com.cskaoyan.bean.wx_user.exception.UserNoLoginException;
import org.apache.catalina.security.SecurityUtil;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.IncorrectCredentialsException;
import org.apache.shiro.authc.UnknownAccountException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author liXiaoFei
 * @date 2021/10/21 16:01
 */
@RestControllerAdvice
public class WxUserExceptionControllerAdvice {

    @ExceptionHandler(IncorrectCredentialsException.class)
    public WxRespVo loginException(){
        return WxRespVo.error("密码错误");
    }

    @ExceptionHandler(WxFeedbackParamException.class)
    public WxRespVo wxFeedbackParamException(WxFeedbackParamException exception){
        return WxRespVo.errorParam(exception.getMessage());
    }

    @ExceptionHandler(AddFeedbackException.class)
    public WxRespVo addFeedbackException(){
        return WxRespVo.errorParam("意见反馈失败");
    }

    @ExceptionHandler(UnknownAccountException.class)
    public WxRespVo loginExceptionByUsername(){
        return WxRespVo.error("账号没有记录");
    }

    @ExceptionHandler(DeleteFootprintException.class)
    public WxRespVo deleteFootprintException(){
        return WxRespVo.error("删除失败");
    }

    @ExceptionHandler(AddUserException.class)
    public WxRespVo addUserException(){
        return WxRespVo.errorRegister();
    }

    @ExceptionHandler(UserNoLoginException.class)
    public WxRespVo userNoLoginException(){
        return WxRespVo.errorWxLogin();
    }
}
